<?php

/**
 * Permet de connaitre les entrées dans la DB
 */
include "./php/evenement.class.php";
include "./php/joueur.class.php";
include "./php/partie.class.php";

if (!$db = sqlite_open('data.sqlite', 0666, $sqliteerror)) {
    die($sqliteerror);
}
echo "<h1>Test DB</h1><h2>Parties</h2>";
$q = sqlite_query($db, "
            SELECT * FROM partie");
while ($d = sqlite_fetch_array($q)) {
    $p = new Partie(intval($d["idpartie"]), $db);
    var_dump($p->tobigarray());
    echo "<hr/>";
}
echo "<h2>Joueurs Sans parties</h2>";
$q=  sqlite_query($db, "SELECT * FROM joueur WHERE idpartie=null");
while ($d = sqlite_fetch_array($q)) {
    $j=new Joueur($d["nomjoueur"], $db);
    var_dump($j->toarray());
    echo "<hr/>";
}
echo "<h2>Evenements de parties inconnues</h2>";
$q=  sqlite_query($db, "SELECT * FROM evenement e WHERE idpartie NOT IN (select idpartie from partie);");
while($d=  sqlite_fetch_array($q)){
    $evenement=new Evenement($db, $d["idevenement"]);
    var_dump($evenement->toArray());
}
?>
